﻿@model Common.UserProductRating

@{
    ViewBag.Title = "ProductRatings";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<h2>ProductRatings</h2>

<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
<script type="text/javascript">

    $(document).ready(function () {
        var Select = document.getElementById("SelectNumber");
        var Choices = ["1 Star", "2 Star", "3 Star", "4 Star", "5 Star"];

        for (var i = 0; i < Choice.length; i++) {
            var c = Choic[i];
            var a = document.createElement("Choice");
            a.textContent = c;
            a.value = c;
            Select.appendChild(a);
        }

        var Rating = document.getElementById("SelectNumber").value;
        $('#BtnRate').click(function () {
            $.ajax({
                url: '@Url.Action("ProductRatings","Product")',
                type: 'post',
                cache: false,
                data: { ddlValue: rating },
                success: function (result) { alert('Operation Succeed') }
            });
            return false;
        });

    });

</script>



@using (Html.BeginForm()) {
    @Html.ValidationSummary(true)
    <fieldset>
        <legend>Rating</legend>

        <div class="editor-label">
            @Html.LabelFor(model => model.Rating_1)
        </div>
        <div class="editor-field">
            <select id="SelectNumber"></select>
        </div>

        <p>
            <input type="submit" value="Rate" id="BtnRate"/>
        </p>
    </fieldset>
}

